﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpdateAndDeleteTaiKhoan.aspx.cs" Inherits="TraCuuTinRaoVat.QuanLyChuyenMucChinh" MasterPageFile="~/Masterpage/AdminSite.Master" %>

<asp:Content ContentPlaceHolderID="MainContent" ID="maincotent" runat="server">

    <div class="newsbox_noleft">
    <div class="newsbox_noleft_header"><h4>HIỆU CHỈNH TÀI KHOẢN</h4></div>
    <div class="newsbox_noleft_content">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="lblTrungTenDN" runat="server" Font-Bold="True" ForeColor="Red" 
            Visible="False"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
        <asp:Label ID="lblTrungEmail" runat="server" Font-Bold="True" ForeColor="Red" 
            Visible="False"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
        <asp:Label ID="lblTrungCMND" runat="server" Font-Bold="True" ForeColor="Red" 
            Visible="False"></asp:Label>
        &nbsp;<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="MaNguoiDung" 
            DataSourceID="SqlDataSource1" EnableModelValidation="True" 
            onrowupdating="GridView1_RowUpdating" CellPadding="4" ForeColor="#333333" 
            GridLines="None" Height="547px" Width="717px"
          
          >
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update"></asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Họ Tên" SortExpression="TenNguoiDung">
                    <EditItemTemplate>
                        <br />
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TenNguoiDung") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                            ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("TenNguoiDung") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                 
                  <asp:TemplateField HeaderText="Loại" SortExpression="TenLoaiNguoiDung">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox17" runat="server" 
                            Text='<%# Bind("TenLoaiNguoiDung") %>' ReadOnly="True"></asp:TextBox>
                       
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label14" runat="server" Text='<%# Bind("TenLoaiNguoiDung") %>'></asp:Label>
                    </ItemTemplate>
                      <ItemStyle Width="50px" />
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Tên đăng nhập" SortExpression="TenDangNhap">
                    <EditItemTemplate>
                        <br />
                        <asp:TextBox ID="txtTenDN" runat="server" Text='<%# Bind("TenDangNhap") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                            ControlToValidate="txtTenDN" ErrorMessage="*"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("TenDangNhap") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Mật khẩu" SortExpression="MatKhau">
                    <EditItemTemplate>
                        <br />
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("MatKhau") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
                            ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                        <asp:CustomValidator ID="CustomValidator1" runat="server" 
                            ControlToValidate="TextBox2" ErrorMessage="(6-20 kí tự)" 
                            onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("MatKhau") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
               
                <asp:TemplateField HeaderText="Kích hoạt" 
                    SortExpression="TinhTrangKichHoat">
                    <EditItemTemplate>
                        <br />
                        <asp:TextBox ID="TextBox6" runat="server" 
                            Text='<%# Bind("TinhTrangKichHoat") %>'></asp:TextBox>
                       
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" 
                            ControlToValidate="TextBox6" ErrorMessage="*"></asp:RequiredFieldValidator>
                       
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label9" runat="server" Text='<%# Bind("TinhTrangKichHoat") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="70px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Hết hạn" 
                    SortExpression="ThoiGianHetHan">
                    <EditItemTemplate>
                        <br />
                        <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("ThoiGianHetHan") %>'></asp:TextBox>
                       
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" 
                            ControlToValidate="TextBox8" ErrorMessage="*"></asp:RequiredFieldValidator>
                       
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label11" runat="server" 
                            Text='<%# Bind("ThoiGianHetHan", "{0:d}") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="70px" />
                </asp:TemplateField>
                 <asp:CheckBoxField DataField="ViPham" HeaderText="Vi phạm" 
                    SortExpression=" Deleted" >
                 <ItemStyle Width="50px" />
                </asp:CheckBoxField>
                 <asp:CheckBoxField DataField="Deleted" HeaderText="Đã xóa" 
                    SortExpression=" Deleted" >
                <ItemStyle Width="50px" />
                </asp:CheckBoxField>
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#CCCCCC" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" 
                Width="50px" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
            DeleteCommand="DELETE FROM [NGUOI_DUNG] WHERE [MaNguoiDung] = @MaNguoiDung" 
            InsertCommand="INSERT INTO [NGUOI_DUNG] ([MaLoaiNguoiDung], [TenNguoiDung], [TenDangNhap], [MatKhau], [Email], [DienThoai], [SoCMND], [DiaChi], [MaKichHoat], [TinhTrangKichHoat], [ThoiGianDangKy], [ThoiGianHetHan], [ViPham],[Deleted]) VALUES (@MaLoaiNguoiDung, @TenNguoiDung, @TenDangNhap, @MatKhau, @Email, @DienThoai, @SoCMND, @DiaChi, @MaKichHoat, @TinhTrangKichHoat, @ThoiGianDangKy, @ThoiGianHetHan, @ViPham, @Deleted)" 
            SelectCommand="SELECT LOAI_NGUOI_DUNG.TenLoaiNguoiDung, NGUOI_DUNG.* FROM LOAI_NGUOI_DUNG INNER JOIN NGUOI_DUNG ON LOAI_NGUOI_DUNG.MaLoaiNguoiDung = NGUOI_DUNG.MaLoaiNguoiDung"
            UpdateCommand="UPDATE [NGUOI_DUNG] SET  [TenNguoiDung] = @TenNguoiDung, [TenDangNhap] = @TenDangNhap, [MatKhau] = @MatKhau, [Email] = @Email, [DienThoai] = @DienThoai, [SoCMND] = @SoCMND, [DiaChi] = @DiaChi, [MaKichHoat] = @MaKichHoat, [TinhTrangKichHoat] = @TinhTrangKichHoat, [ThoiGianDangKy] = @ThoiGianDangKy, [ThoiGianHetHan] = @ThoiGianHetHan, [ViPham] = @ViPham, [Deleted] = @Deleted WHERE [MaNguoiDung] = @MaNguoiDung">
            <DeleteParameters>
                <asp:Parameter Name="MaNguoiDung" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="MaLoaiNguoiDung" Type="Int32" />
                <asp:Parameter Name="TenNguoiDung" Type="String" />
                <asp:Parameter Name="TenDangNhap" Type="String" />
                <asp:Parameter Name="MatKhau" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="DienThoai" Type="String" />
                <asp:Parameter Name="SoCMND" Type="String" />
                <asp:Parameter Name="DiaChi" Type="String" />
                <asp:Parameter Name="MaKichHoat" Type="Int32" />
                <asp:Parameter Name="TinhTrangKichHoat" Type="Int32" />
                <asp:Parameter Name="ThoiGianDangKy" Type="DateTime" />
                <asp:Parameter Name="ThoiGianHetHan" Type="DateTime" />
                <asp:Parameter Name="TrangThai" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="MaLoaiNguoiDung" Type="Int32" />
                <asp:Parameter Name="TenNguoiDung" Type="String" />
                <asp:Parameter Name="TenDangNhap" Type="String" />
                <asp:Parameter Name="MatKhau" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="DienThoai" Type="String" />
                <asp:Parameter Name="SoCMND" Type="String" />
                <asp:Parameter Name="DiaChi" Type="String" />
                <asp:Parameter Name="MaKichHoat" Type="Int32" />
                <asp:Parameter Name="TinhTrangKichHoat" Type="Int32" />
                <asp:Parameter Name="ThoiGianDangKy" Type="DateTime" />
                <asp:Parameter Name="ThoiGianHetHan" Type="DateTime" />              
                      <asp:Parameter Name = "ViPham" Type="Boolean" />
                <asp:Parameter Name = "Deleted" Type="Boolean" />
            </UpdateParameters>
        </asp:SqlDataSource>
    
        <br />
    
</div>
</div>
</asp:Content>